import {
  q as n,
  p as ee,
  ap as te,
  X as N,
  f as ae,
  H as le,
  av as A,
  aw as se,
  k as t,
  l as a,
  m as s,
  ax as ie,
  as as c,
  az as ne,
  at as W,
  ay as re
} from "./index-b50e6ef9.js";
import { d as ue, r as z } from "./order-9978affc.js";
function D(m) {
  return (
    typeof m == "function" ||
    (Object.prototype.toString.call(m) === "[object Object]" && !re(m))
  );
}
function fe(m) {
  const y = n([]),
    F = n([]),
    B = n([]),
    E = n([]),
    w = n({}),
    f = n(!0);
  n({}), ee();
  const h = n(1),
    _ = n(),
    C = n(),
    g = n(10),
    d = n([]),
    I = n(),
    b = n(),
    L = te("reload"),
    v = N({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    V = N({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    J = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "ID",
        prop: "order_id",
        minWidth: 80,
        formatter: ({ order_id: e }) => `1${e}`
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 130 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "商品名称",
        prop: "wares_name",
        minWidth: 250,
        formatter: ({
          wares_name: e,
          store_name: l,
          store_code: u,
          notes: r,
          activity: o,
          remarks: i
        }) =>
          t("div", null, [
            t("div", null, [e]),
            l
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  D(l) ? l : { default: () => [l] }
                )
              : "",
            u
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("门店码:"), u] }
                )
              : "",
            t("div", null, [
              r
                ? t(
                    a("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    D(r) ? r : { default: () => [r] }
                  )
                : ""
            ]),
            t("div", null, [
              o == 1
                ? t(
                    a("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [s("已赠送")] }
                  )
                : ""
            ]),
            t("div", null, [
              i
                ? t(
                    a("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    D(i) ? i : { default: () => [i] }
                  )
                : ""
            ])
          ])
      },
      { label: "产品金额", prop: "wares_price", minWidth: 100 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      { label: "积分折扣", prop: "hock_price", minWidth: 80 },
      { label: "折扣支付", prop: "other_price", minWidth: 80 },
      {
        label: "支付方式",
        prop: "pay_type",
        minWidth: 90,
        formatter: ({ pay_type: e }) => {
          if (e == 1) return "积分";
          if (e == 2) return "微信";
          if (e == 3) return "支付宝";
          if (e == 4) return "复消积分";
        }
      },
      {
        label: "内含数量",
        prop: "all_bottle",
        minWidth: 100,
        formatter: ({ all_bottle: e, wares_unit: l }) => e + l
      },
      { label: "购买数量", prop: "wares_num", minWidth: 80 },
      {
        label: "状态",
        prop: "status",
        minWidth: 150,
        formatter: ({ status: e, track_name: l, content: u }) => {
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [s("已预约")] }
            );
          if (e == 2)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("已完成")] }
            );
        }
      },
      { label: "下单时间", minWidth: 180, prop: "create_time" }
    ],
    O = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 100,
        formatter: ({ user_place: e }) => {
          if (e == 0)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("暂无")] }
            );
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星合伙人")] }
            );
          if (e == 2)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星合伙人")] }
            );
          if (e == 3)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星合伙人")] }
            );
          if (e == 4)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星合伙人")] }
            );
          if (e == 5)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("五星合伙人")] }
            );
          if (e == 6)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星联创")] }
            );
          if (e == 7)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星联创")] }
            );
          if (e == 8)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星联创")] }
            );
          if (e == 9)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("四星联创")] }
            );
          if (e == 10)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("一星董事")] }
            );
          if (e == 11)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("二星董事")] }
            );
          if (e == 12)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("三星董事")] }
            );
        }
      },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "积分",
        prop: "income",
        minWidth: 100,
        formatter: ({ income: e, money: l }) => e || l
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("已发放")] }
            );
          if (e == 2)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [s("未发放")] }
            );
        }
      },
      { label: "类型", prop: "type_name", minWidth: 100 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 120 }
    ],
    U = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "收件人手机号", prop: "phone", minWidth: 120 },
      { label: "收件人姓名", prop: "name", minWidth: 120 },
      { label: "收件人地址", prop: "address", minWidth: 150 },
      { label: "商品信息", prop: "wares", minWidth: 150 },
      { label: "订单编号", prop: "order_code", minWidth: 150 },
      {
        label: "支付金额",
        prop: "pay_price",
        minWidth: 100,
        formatter: ({ pay_price: e }) =>
          t(
            "div",
            { style: "color:#59AB74;font-weight: bold;font-size:16px;" },
            [e]
          )
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: l }) => {
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [s("待发货")] }
            );
          if (e == 2)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [s("待自提")] }
            );
          if (e == 3 && l != "自提")
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("已快递")] }
            );
          if (e == 3 && l == "自提")
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("已自提")] }
            );
        }
      },
      { label: "内含几瓶", prop: "jiping", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) =>
          ie(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "订单备注", prop: "remarks", minWidth: 100 },
      { label: "备注", prop: "notes", minWidth: 100 },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    R = ae(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function j(e) {
    const l = { order_id: e.order_id },
      u = JSON.stringify(l),
      o = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(u)) },
      i = await ue(o);
    i.code == 200 &&
      ((F.value = i.data.income),
      (B.value = i.data.dispel),
      (E.value = i.data.freeze),
      (w.value = i.data.indent));
  }
  async function k(e) {
    ne(e);
  }
  async function M(e) {
    const l = { id: e.id },
      u = JSON.stringify(l),
      o = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(u)) },
      i = await questionDelete(o);
    i.code == 200
      ? (W("删除成功", { type: "success" }), L())
      : W(i.msg, { type: "error" });
  }
  function T() {}
  function Y(e) {
    (g.value = e), x(void 0, e);
  }
  function H(e) {
    (h.value = e), x(e, void 0);
  }
  function $(e) {}
  function q(e) {
    (V.text = `正在加载第${e}页...`),
      (f.value = !0),
      A(600).then(() => {
        f.value = !1;
      });
  }
  async function X(e, l, u = [], r, o) {
    (d.value = []),
      u.map(Q => {
        const Z = Q,
          P = new Date(Z);
        d.value.push(
          P.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (f.value = !0),
      (b.value = e),
      (_.value = r),
      (C.value = o),
      (I.value = l);
    const i = {
        page: h.value,
        pagesize: g.value,
        status: e,
        user_phone: isNaN(l) ? void 0 : l,
        user_id: isNaN(r) ? void 0 : r,
        user_name: isNaN(l) ? l : void 0,
        start: d.value[0],
        end: d.value[1],
        store_code: o,
        action: "add_time"
      },
      p = JSON.stringify(i),
      K = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(p)) },
      { data: S } = await z(K);
    (y.value = S.indent.data),
      (v.total = S.indent.total),
      setTimeout(() => {
        f.value = !1;
      }, 500);
  }
  async function x(e = h.value, l = g.value) {
    const u = {
        page: e,
        pagesize: l,
        status: b.value,
        start: d.value[0],
        end: d.value[1],
        user_phone: I.value,
        user_id: _.value,
        store_code: C.value,
        action: "add_time"
      },
      r = JSON.stringify(u),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(r)) },
      p = await z(i);
    p.code === 200
      ? ((y.value = p.data.indent.data),
        (v.total = p.data.indent.total),
        setTimeout(() => {
          f.value = !1;
        }, 500))
      : W(p.msg, { type: "error" });
  }
  const G = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    le(() => {
      A().then(() => {
        const { setWatermark: e } = se(m.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        x();
    }),
    {
      loading: f,
      columns: J,
      dataList: y,
      userColumns: O,
      pagination: v,
      buttonClass: R,
      userDatilList: F,
      userDatilListDisple: B,
      userDatilListFreeze: E,
      orderInfo: w,
      columnsTable: U,
      count: h,
      pageCount: g,
      formattedDate: d,
      typeCount: b,
      handleLookUserDatil: j,
      onSearch: X,
      resetForm: G,
      handleaddUser: T,
      handleUpdate: k,
      handleDelete: M,
      handleSizeChange: Y,
      handleCurrentChange: H,
      handleSelectionChange: $,
      onCurrentChange: q
    }
  );
}
export { fe as useRole };
